package org.component.item 
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	import org.component.Clist;
	import org.component.events.ListEvent;
	
	import com.peachcastle.core.Display;
	
	/**
	 * ...
	 * @author ...
	 */
	public class ClistItem extends Display
	{
		
		//主体;
		protected var _subject:Clist = null;
		
		
		public function ClistItem(ui:MovieClip =null) 
		{
			super(ui);
		}
		
		override protected function initialization():void 
		{
			super.initialization();
			
			assest.buttonMode = true;
			assest.mouseChildren = false;
		}
		
		override protected function configEventListeners():void 
		{
			super.configEventListeners();
			
			assest.addEventListener(MouseEvent.CLICK, onAssestClick);
		}
		
		private function onAssestClick(e:MouseEvent):void
		{
			e.stopPropagation();
			
			var evt:ListEvent = new ListEvent(ListEvent.LIST_SELECT);
			evt.data = listdata;
			
			_subject.dispatchEvent(evt);
			evt = null;
		}
		
		public function getSubject(list:Clist = null):void
		{
			_subject = list;
		}
		
		public function setLabel(data:String = ''):void
		{
			assest['label'].text = data;
		}
		
		public function dispose():void
		{
			super.hideAssest();
		}
		
		private var _index:int = -1;
		
		public function get index():int { return _index; }
		public function set index(value:int):void { _index = value; }
		
		
		private var _select:Boolean = false;
		public function get select():Boolean { return _select;}
		public function set select(value:Boolean):void
		{
			_select = value;
		}
		
		public function get listdata():String { return assest['label'].text; }
		
	}

}